<?php
namespace app\api\controller;
use app\common\controller\BaseApi;
/**
 * 人脸模板上传
 */
class UploadFace extends  BaseApi{
	public function _initialize(){
	}
	
	/**
	 * 上传图片
	 * base64编码
	 */
	public function upload(){
		if(!empty(input("files",''))){
			$dir="./data/face/".date("Ymd")."/";
			if(!file_exists($dir)){
				mkdir($dir);
			}
			$file_name=$dir.input("filename");
			$fopen=fopen($file_name, "wb");			
			file_put_contents($file_name,base64_decode(str_replace(" ", "+",input("files"))));
			fclose($fopen);		
			return $this->ajax_success();		
		}else{
			return $this->ajax_error("文件为空");
		}
	} 
	
}
